<?php include_stylesheets_for_form($form) ?>
<?php include_javascripts_for_form($form) ?>

<form id="form_banner" name="form_banner" action="<?php echo url_for('banner/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id_item='.$form->getObject()->getIdItem() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<?php if (!$form->getObject()->isNew()): ?>
<input type="hidden" name="sf_method" value="put" />
<input type="hidden" name="id_item" value="<?php echo $form->getObject()->getIdItem() ?>" />

<?php endif; ?>
<?php echo $form->renderHiddenFields() ?>
	
	<div class="tabs">
	    <ul>
	        <li><a href="#tab_dados">Dados</a></li>
	        <?php if (!$form->getObject()->isNew()): ?>
	            <li><a href="<?php echo url_for('midia/arquivos?ref_name=id_item&ref_value='.$form->getObject()->getIdItem().'&hasmany=false'); ?>">Arquivo(s)</a></li>
	        <?php else: ?>
	            <li><a href="#tab_midia">Imagens(s)</a></li>
	        <?php endif; ?>
	    </ul>
	    <div id="tab_dados">
	    	<input type="hidden" name="item[id_tipo]" value="<?php echo Tipo::BANNERS; ?>" />
			<input type="hidden" name="item[is_top]" value="N" />
			<table class="form">
				<tbody>
					<tr>
						<th><?php echo $form['nm_item']->renderLabel() ?></th>
						<td><?php echo $form['nm_item'] ?> <?php echo form_error('nm_item'); ?>
						</td>
					</tr>
					<tr>
						<th><?php echo $form['ds_url']->renderLabel() ?></th>
						<td><?php echo $form['ds_url'] ?> <?php echo form_error('ds_url'); ?>
						</td>
					</tr>
					<tr>
						<th><?php echo $form['is_top']->renderLabel() ?></th>
						<td><?php echo $form['is_top'] ?> <?php echo form_error('is_top'); ?>
						</td>
					</tr>
					<tr>
						<th><?php echo $form['st_item']->renderLabel() ?></th>
						<td><?php echo $form['st_item'] ?> <?php echo form_error('st_item'); ?>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		<?php if ($form->getObject()->isNew()): ?>
	    <div id="tab_midia">
	        <?php include_component('midia', 'new', array('form' => $form, 'hasmany' => false)); ?>
	    </div>
	    <?php endif; ?>
	</div>
	

<?php
	comandos_form(
		link_to(
			':: Listar ::',
			'banner/list',
			array('class' => 'botao')
		),
		submit_tag(':: Salvar ::')
	);
?>
</form>

<script type="text/javascript">
$(function()
{
	System.setdata.tab();
    System.formdata.save(new Array("msgAlerta", "Atenção:"));
});
</script>